CREATE OR REPLACE VIEW VPI.VIEW_WASH_ISTR_DOCUMENT AS
SELECT
	I.CYCLE_ID,
	I.ISTR_ID,
	I.ISTR_ORDER,
	I.ISTR_TYPE,
	DECODE(I.ISTR_TYPE,
		'COPY',		C.SRC_VIEW,
		'MERGE',	M.SRC_VIEW,
		'MUP_MK',	L.SRC_VIEW)			AS SRC_VIEW,
	DECODE(I.ISTR_TYPE,
		'COPY',		C.SRC_FILTER,
		'MERGE',	M.SRC_FILTER,
		'MUP_MK',	L.SRC_FILTER)		AS SRC_FILTER,
	DECODE(I.ISTR_TYPE,
		'MERGE',	M.JOIN_COLUMNS,
		'MUP_MK',	L.SRC_KEY_COLUMNS,
		'MUP_NA',	N.MAKE_UP_KEYS)		AS SRC_KEY_COLUMNS,
	DECODE(I.ISTR_TYPE,
		'MERGE',	M.UPDATE_COLUMNS,
		'MUP_MK',	L.SRC_VALUES,
		'MUP_NA',	N.MAKE_UP_VALUES)	AS SRC_VALUES,
	DECODE(I.ISTR_TYPE,
		'DELETE',	D.DST_TABLE,
		'COPY',		C.DST_TABLE,
		'MERGE',	M.DST_TABLE,
		'CHK_UK',	U.DST_TABLE,
		'RNK_DK',	R.DST_TABLE,
		'MUP_MK',	L.DST_TABLE,
		'MUP_NA',	N.DST_TABLE)		AS DST_TABLE,
	DECODE(I.ISTR_TYPE,
		'DELETE',	D.DST_FILTER,
		'CHK_UK',	U.DST_FILTER,
		'RNK_DK',	R.DST_FILTER)		AS DST_FILTER,
	DECODE(I.ISTR_TYPE,
		'MERGE',	M.JOIN_COLUMNS,
		'CHK_UK',	U.KEY_COLUMNS,
		'RNK_DK',	R.KEY_COLUMNS,
		'MUP_MK',	L.DST_KEY_COLUMNS,
		'MUP_NA',	N.DST_KEY_COLUMNS)	AS DST_KEY_COLUMNS,
	DECODE(I.ISTR_TYPE,
		'MERGE',	M.UPDATE_COLUMNS,
		'MUP_MK',	L.DST_VAL_COLUMNS,
		'MUP_NA',	N.DST_VAL_COLUMNS)	AS DST_VAL_COLUMNS,
	U.SET_EXPR_IF_UNIQUE,
	U.SET_EXPR_IF_DUPLICATE,
	M.INSERT_COLUMNS					AS MERGE_INSERT_COLUMNS,
	R.RN_COLUMN							AS DUP_ROW_NUMBER_COLUMN,
	R.ORDER_BY							AS DUP_ORDER_BY,
	I.DESCRIPTION_
FROM
	VPI.WASH_ISTR				I
LEFT JOIN
	VPI.WASH_ISTR_DELETE		D
ON (D.ISTR_ID	= I.ISTR_ID)
LEFT JOIN
	VPI.WASH_ISTR_COPY			C
ON (C.ISTR_ID	= I.ISTR_ID)
LEFT JOIN
	VPI.WASH_ISTR_MERGE			M
ON (M.ISTR_ID	= I.ISTR_ID)
LEFT JOIN
	VPI.WASH_ISTR_CHK_UK		U
ON (U.ISTR_ID	= I.ISTR_ID)
LEFT JOIN
	VPI.WASH_ISTR_RNK_DK		R
ON (R.ISTR_ID	= I.ISTR_ID)
LEFT JOIN
	VPI.WASH_ISTR_MUP_MK		L
ON (L.ISTR_ID	= I.ISTR_ID)
LEFT JOIN
	VPI.WASH_ISTR_MUP_NA		N
ON (N.ISTR_ID	= I.ISTR_ID)
ORDER BY
	I.CYCLE_ID,
	I.ISTR_ORDER

WITH READ ONLY;
